/*
 * Camera.java
 *
 * Created on 1 de Julho de 2007, 22:47
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package MapItens;

import Managers.ItemManager;
import java.io.IOException;
import javax.microedition.m3g.Camera;
import javax.microedition.m3g.World;

/**
 *
 * @author JAKE
 */
public class FlunkerCamera extends Item{
    
    private float x = 0;
    
    private float y = 0;
    
    private float z = 0;
    
    private float camera_direction = 0;
    
    static final int CAMERA_GROUP_TRANSFORM_ID = 6;
    
    private Camera camera;
    
    /** Creates a new instance of Camera */
    public FlunkerCamera(ItemManager item_manager, World world) throws IOException {
        super(item_manager, world);
    }
    
    public void update(int worldTime) {
        switch(action){
            case keyForward:
                camera.translate(x,y--,z);
                break;
            case keyBackward:
                camera.translate(x,y++,z);
                break;
        }
    }
    
    public void loadCoordenates(){
        float[] coordenates = new float[3];
        camera.getTranslation(coordenates);
        
        x = coordenates[0];
        y = coordenates[1];
        z = coordenates[2];
    }
    
    public void loadObjects() throws IOException {
        camera  = (Camera) flunker_world.find(CAMERA_GROUP_TRANSFORM_ID);
        if(camera != null){
            loadCoordenates();
        }
    }
    
    
}
